package com.xy.enums;

import lombok.Getter;

import java.util.stream.Stream;

/**
 * @author guojian
 */

@Getter
public enum BlacklistRiskEnum {
	/**
	 * 本地查询.
	 */
	DFX("1", "低风险"),
	/**
	 * 本地查询.
	 */
	ZFX("2", "中风险"),
	/**
	 * 接口查询.
	 */
	GFX("3", "高风险");

	private final String code;
	private final String info;

	BlacklistRiskEnum(String code, String info) {
		this.code = code;
		this.info = info;
	}
	/**
	 * 根据当前枚举的name匹配
	 */
	public static BlacklistRiskEnum match(String val, BlacklistRiskEnum def) {
		return Stream.of(values()).parallel().filter(item -> item.getCode().equalsIgnoreCase(val)).findAny().orElse(def);
	}
	public static BlacklistRiskEnum get(String val) {
		return match(val, null);
	}
}
